//<AlertView With addSubview>
	UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
	CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0,60);
	[alert setTransform:myTransform];
	[myTextField setBackgroundColor:[UIColor whiteColor]];
	[alert addSubview:myTextField];
    [alert show];
    [alert release];


//<String Sort>
NSArray *stringsArray = [NSArray arrayWithObjects:
                         @"string 1",
                         @"String 21",
                         @"string 12",
                         @"String 11",
                         @"String 02", nil];
NSArray *sortedArray = [stringsArray sortedArrayUsingFunction:finderSortWithLocale
                                     context:[NSLocale currentLocale]];
// sortedArray contains { "string 1", "String 02", "String 11", "string 12", "String 21" }


//<Compare String>
NSString *string1 = @"string1";
NSString *string2 = @"string2";
NSComparisonResult result;
result = [string1 compare:string2];
// result = -1 (NSOrderedAscending)
NSString *string10 = @"string10";
NSString *string2 = @"string2";
NSComparisonResult result;
result = [string10 compare:string2];
// result = -1 (NSOrderedAscending)
result = [string10 compare:string2 options:NSNumericSearch];
result = [string_a caseInsensitiveCompare:string_A];
//equivalent to [string_a compare:string_A options:NSCaseInsensitiveSearch]
// result = 1 (NSOrderedDescending)


//<Case-Insensitive Search>
NSString *searchString = @"age";
NSString *beginsTest = @"Agencies";
NSRange prefixRange = [beginsTest rangeOfString:searchString
    options:(NSAnchoredSearch | NSCaseInsensitiveSearch)];
// prefixRange = {0, 3}
NSString *endsTest = @"BRICOLAGE";
NSRange suffixRange = [endsTest rangeOfString:searchString
    options:(NSAnchoredSearch | NSCaseInsensitiveSearch | NSBackwardsSearch)];
// suffixRange = {6, 3}


//<write string to files>
NSString *path = ...;
NSString *string = ...;
NSError *error;
BOOL ok = [string writeToFile:path atomically:YES
                  encoding:NSUnicodeStringEncoding error:&error];
if (!ok) {
    // an error occurred
    NSLog(@"Error writing file at %@\n%@",
              path, [error localizedFailureReason]);
    // implementation continues ...
    

//<Reading String from and Writing Strings to Files and URLs>
NSString *path = ...;
NSError *error;
NSString *stringFromFileAtPath = [[NSString alloc]
                                      initWithContentsOfFile:path
                                      encoding:NSUTF8StringEncoding
                                      error:&error];
if (stringFromFileAtPath == nil) {
    // an error occurred
    NSLog(@"Error reading file at %@\n%@",
              path, [error localizedFailureReason]);
    // implementation continues ...

    
//<Strings and Non-ASCII Characters>
NSString *s = [NSString stringWithFormat:@"Long %C dash", 0x2014];
NSString *s = [NSString stringWithUTF8String:"Long \xe2\x80\x94   dash"];


//<NSString Format>
NSString *string1 = [NSString stringWithFormat:@"A string: %@, a float: %1.2f",
        @"string", 31415.9265];

// string1 is "A string: string, a float: 31415.93"
NSNumber *number = [NSNumber numberWithInt:1234];
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:[NSDate date]
        forKey:@"date"];
NSString *baseString = @"Base string.";
NSString *string2 = [baseString stringByAppendingFormat:
        @" A number: %@, a dictionary: %@", number, dictionary];
string2 is "Base string. A number: 1234, a dictionary: {date = 2005-10-17 09:02:01 -0700; }"

//<NSString with NSRange>
NSRange twoToSixRange = NSMakeRange(2, 4);
NSString *twoToSix = [source substringWithRange:twoToSixRange];
// twoToSix is @"2345"

NSArray *split = [source componentsSeparatedByString:@"45"];
// split contains { @"0123", @"6789" }

NSString *source = @"0123456789";
NSString *firstFour = [source substringToIndex:4];
// firstFour is @"0123"


//*** (popup-alert string-title string-message string-cancelButtonTitle)
UIAlertView *alert =
  [[UIAlertView alloc] initWithTitle:@"Hello World!"
                             message:@"iPhone, here I come!"
                            delegate:self
                   cancelButtonTitle:@"OK"
                   otherButtonTitles:nil];
    [alert show];
    [alert release];

//---------------------
//*** (format "%@ %@" a b)
NSString *str = [[NSString alloc]
                  initWithFormat:@"Hello, %@", nameTextField.text ];

[str release]

//*** from c char array to NSString
char *utf8String = /* assume this exists */ ;
NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:utf8String];
char *macOSRomanEncodedString = /* assume this exists */ ;
NSString *stringFromMORString =
            [[NSString alloc] initWithCString:macOSRomanEncodedString
                              encoding:NSMacOSRomanStringEncoding];
NSData *shiftJISData =  /* assume this exists */ ;
NSString *stringFromShiftJISData =
            [[NSString alloc] initWithData:shiftJISData
                              encoding:NSShiftJISStringEncoding];

// string append string.
//(concat str1 str2)
NSString *hString = @"Hello";
NSString *hwString = [hString stringByAppendingString:@", world!"];

